// pages/product/product.js
var Protocol = require("../../Controls/Protocol")
var Login = require("../../Controls/Login")
var util = require("../../utils/util")
var DataExchange = require("../../Controls/DataExchange")
var UploadFile = require("../../Controls/UploadFile")
var app = getApp();

var isStarted = false;

var delta = 1;

var data =
  {
    isFold: true,

    indicatorDots: true,
    autoPlay: false,
    interval: 1000,
    duration: 300,

    seller:
    {
      avatarUrl: "../../image/icon_small.jpg",
      nickName: "empty",
    },

    left_time_str: "已结束",
    product_info:
    {
      id: 1,
      name: "商品名称",
      price: 100.00,
      max_price: 1000.00,
      min_price: 1.00,
      left_time: 1000,
      images: ["https://www.baidu.com", "https://www.youku.com"],
      left_count: 10,
      desc: "这是秘袋描述",
    },

    other_userinfo:
    [
      { name: "熊大", avatar: "../../image/1.jpg", qty: 10.00, },
      { name: "熊二", avatar: "../../image/icon_small.jpg", qty: 10.00, },
      { name: "熊大", avatar: "../../image/1.jpg", qty: 10.00, },
      { name: "熊大", avatar: "../../image/1.jpg", qty: 10.00, },
      { name: "熊大", avatar: "../../image/1.jpg", qty: 10.00, },
      { name: "熊大", avatar: "../../image/1.jpg", qty: 10.00, },
      { name: "熊大", avatar: "../../image/1.jpg", qty: 10.00, },

      { name: "熊大", avatar: "../../image/1.jpg", qty: 10.00, },
      { name: "熊大", avatar: "../../image/1.jpg", qty: 10.00, },
      { name: "熊大", avatar: "../../image/1.jpg", qty: 10.00, },
      { name: "熊大", avatar: "../../image/1.jpg", qty: 10.00, },
      { name: "熊大", avatar: "../../image/1.jpg", qty: 10.00, },
      { name: "熊大", avatar: "../../image/1.jpg", qty: 10.00, },
      { name: "熊大", avatar: "../../image/1.jpg", qty: 10.00, },
      
    ],
  }

function onReady() {
  this.Tip = this.selectComponent("#Tip");
}

function btnJoinusIvk() {
  console.log("我也发布");
  console.log(app.globalData.isLogin);
  if (app.globalData.isLogin) {
    console.log(app.globalData.isLogin);
    wx.switchTab({
      url: '../../pages/publish/publish',
      success: function (res)
      { console.log("1" + res); },
      fail: function (res)
      { console.log("2" + res); },
      complete: function () {
        console.log("3");
      }
    })
  }
  else {
    Login.login(result => {
      console.log(result);
      wx.switchTab({
        url: '../../pages/publish/publish',
        success: function (res)
        { console.log("1" + res); },
        fail: function (res)
        { console.log("2" + JSON.stringify(res)); },
        complete: function () {
          console.log("3");
        }
      })
    });
  }
}

function btnHelpIvk() {
  this.Tip.showDialog("hello world", "12123123131");
}

function toggle() {
  this.setData({ isFold: !this.data.isFold })
}

var operation =
  {
    data,
    onReady,
    btnJoinusIvk,
    btnHelpIvk,
    toggle,
  };

Page(operation)

